home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / config / mpw / g-mpw-make.sed < prev    next >
Encoding:
Text File  |  1996-07-12  |  9.2 KB  |  290 lines

  1. # Sed commands to translate Unix makefiles into MPW makefiles.
  2. # These are nominally generic, but work best on the makefiles used
  3. # for GNU programs.
  4.  
  5. # Whack out any commented-out lines that are probably commands;
  6. # they can only cause trouble later on.
  7. /^#    /d
  8.  
  9. # Change dependency char.
  10. /:$/s/:/ \\Option-f/g
  11. /^[^     :#][^:]*:/s/\([     ]*\):\([     ]*\)/ \\Option-f /g
  12.  
  13. # Change syntax of Makefile vars.
  14. /\$/s/\${\([a-zA-Z0-9_-]*\)}/{\1}/g
  15. /\$/s/\$(\([a-zA-Z0-9_-]*\))/{\1}/g
  16. / $@/s/ $@/ {Targ}/
  17.  
  18. # Double-$ are literals to Unix but not to MPW make.
  19. /\$\$/s/\$\$/$/g
  20.  
  21. # Change pathname syntax.
  22. /\//s,\.\./\/\.\./,:::,g
  23. /\//s,\.\./,::,g
  24. /\.\//s,\./,:,g
  25. /\//s,/,:,g
  26. # Undo excess changes.
  27. /and/s,and:or$,and/or,
  28. /and/s,and:or ,and/or ,
  29. /want/s,want:need,want/need,
  30. # Fixing up sed commands.
  31. /-e/s_":\([^:]*\):d"_"/\1/d"_g
  32. /-e/s_":\([^:]*\):,:\([^:]*\):d"_"/\1/,/\2/d"_g
  33.  
  34. /=/s/ = \.$/ = :/
  35.  
  36. # Comment out any explicit srcdir setting.
  37. /srcdir/s/^srcdir/# srcdir/
  38.  
  39. /BASEDIR/s/^BASEDIR =.*$/BASEDIR = "{srcroot}"/
  40. /{BASEDIR}:/s/{BASEDIR}:/{BASEDIR}/g
  41. /{srcdir}:/s/{srcdir}:/"{srcdir}"/g
  42. /"{srcdir}":/s/"{srcdir}":/"{srcdir}"/g
  43.  
  44. # Tweak some conventions that are backwards for the Mac.
  45. /bindir/s/{exec_prefix}:bin/{exec_prefix}bin:/
  46. /libdir/s/{exec_prefix}:lib/{exec_prefix}lib:/
  47.  
  48. # Comment out settings of anything set by mpw host config.
  49. /CC/s/^CC *=/#CC =/
  50. /CFLAGS/s/^CFLAGS *=/#CFLAGS =/
  51. /AR/s/^AR *=/#AR =/
  52. /AR_FLAGS/s/^AR_FLAGS *=/#AR_FLAGS =/
  53. /RANLIB/s/^RANLIB *=/#RANLIB =/
  54. /CC_LD/s/^CC_LD *=/#CC_LD =/
  55. /LDFLAGS/s/^LDFLAGS *=/#LDFLAGS =/
  56.  
  57. # Change -I usages. (not for GCC)
  58. /-I/s/-I\./-i :/g
  59. /-I/s/-I::bfd/-i ::bfd:/g
  60. /-I/s/-I::include/-i ::include:/g
  61. /-I/s/-I/-i /g
  62.  
  63. # Change -D usage. (not for GCC)
  64. /-D/s/\([ =]\)-D\([^ ]*\)/\1-d \2/g
  65.  
  66. # Change continuation char.
  67. /\\$/s/\\$/\\Option-d/
  68.  
  69. # Change wildcard char.
  70. /\*/s/\*/\\Option-x/g
  71.  
  72. # Change path of various types of source files.  This rule does not allow
  73. # for file names with multiple dots in the name.
  74. /\.[chly]/s/\([     ><=]\)\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/\1"{s}"\2.\3/g
  75. /\.[chly]/s/^\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/"{s}"\1.\2/
  76. # Allow files named *.tab.[ch] as a special case.
  77. /\.tab\.[ch]/s/\([     ><=]\)\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/\1"{s}"\2.\3/g
  78. /\.tab\.[ch]/s/^\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/"{s}"\1.\2/
  79. # Fix some overenthusiasms.
  80. /{s}/s/"{s}""{srcdir}"/"{srcdir}"/g
  81. /{s}/s/"{s}"{\([a-zA-Z0-9_]*\)dir}/"{\1dir}"/g
  82. /{s}/s/"{s}"{\([a-zA-Z0-9_]*\)DIR}/"{\1DIR}"/g
  83. /{s}/s/"{s}""{\([a-zA-Z0-9_]*\)dir}"/"{\1dir}"/g
  84. /{s}/s/"{s}""{\([a-zA-Z0-9_]*\)DIR}"/"{\1DIR}"/g
  85. /{s}/s/"{s}":/:/g
  86. /{s}/s/^"{s}"//g
  87. /{s}/s/"{s}""{s}"/"{s}"/g
  88. /{s}/s/"{s}""{srcdir}"/"{s}"/g
  89. /{s}/s/"{srcdir}""{s}"/"{s}"/g
  90.  
  91. # The .def files are also typically source files.
  92. /\.def/s/\([     ><]\)\([-a-zA-Z0-9_${}:"]*\)\.def/\1"{s}"\2.def/g
  93. /\.def/s/^\([-a-zA-Z0-9_${}:"]*\)\.def/"{s}"\1.def/g
  94.  
  95. # Change extension and path of objects.
  96. /\.o/s/\([     =]\)\([-a-zA-Z0-9_${}:"]*\)\.o/\1"{o}"\2.c.o/g
  97. /\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.o/"{o}"\1.c.o/
  98. # Allow *.tab.o files as a special case of a 2-dot-name file.
  99. /\.o/s/\([     =]\)\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/\1"{o}"\2.tab.c.o/g
  100. /\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/"{o}"\1.tab.c.o/
  101. # Clean up.
  102. /"{o}"/s/"{o}""{o}"/"{o}"/g
  103. /"{o}"/s/^"{o}"\([a-zA-Z0-9_]*\)=/\1=/
  104.  
  105. # Change extension of libs.
  106. /\.a/s/lib\([a-z]*\)\.a/lib\1.o/g
  107.  
  108. # Remove non-fail option.
  109. /-/s/^\([     ]*\)-/\1/
  110. # Fix overeagernesses - assumes no one-letter commands.
  111. /^[     ]*[a-z] /s/^\([     ]*\)\([a-z]\) /\1-\2 /
  112.  
  113. # Remove non-echo option. (watch out for autoconf things)
  114. /@/s/^\([     ]*\)@/\1/
  115.  
  116. # Change cp to Duplicate.
  117. # Catenate is perhaps more accurate, but the pattern would have to
  118. # identify the output file and add a '>' redirection into it.
  119. /cp/s/^\([     ]*\)cp /\1Duplicate -d -y /
  120. # Change mv to Rename.
  121. /mv/s/^\([     ]*\)mv /\1Rename -y /
  122. /Rename/s/^\([     ]*\)Rename -y -f/\1Rename -y/
  123. # Change rm to Delete.
  124. /rm -rf/s/^\([     ]*\)rm -rf /\1Delete -i -y /
  125. /rm -f/s/^\([     ]*\)rm -f /\1Delete -i -y /
  126. /rm/s/^\([     ]*\)rm /\1Delete -i -y /
  127. # Note that we don't mess with ln - directory-specific scripts
  128. # must decide what to do with symlinks.
  129. # Change cat to Catenate.
  130. /cat/s/^\([     ]*\)cat /\1Catenate /
  131. # Change touch to mpw-touch.
  132. /touch/s/^\([     ]*\)touch /\1mpw-touch /
  133. # Change mkdir to NewFolder.
  134. /mkdir/s/^\([     ]*\)mkdir /\1NewFolder /
  135. # Change var setting to Set.
  136. /=/s/^\([     ]*\)\([-a-zA-Z0-9_]*\)=\([^;]*\); \\Option-d/\1Set \2 \3/
  137.  
  138. # Change tests.
  139. /if /s/if \[ *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/
  140. /if /s/if \[ *-f \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/
  141. /if /s/if \[ ! *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/
  142. /if /s/if \[ ! *-f \([^ ]*\) ] *; *then \\Option-d/If "`Exists "\1"`" == ""/
  143.  
  144. /if /s/if \[ *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/
  145. /if /s/if \[ *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/
  146. /if /s/if \[ ! *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/
  147. /if /s/if \[ ! *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" == ""/
  148.  
  149. /if /s/if \[ -d \([^ ]*\) ] *; then true *; else mkdir \([^ ;]*\) *; fi/If "`Exists "\1"`" != "" NewFolder \2 End If/
  150.  
  151. /if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *\\Option-d/If "\1" == "\2"/
  152. /if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *then *\\Option-d/If "\1" == "\2"/
  153.  
  154. /if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/
  155. /if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/
  156.  
  157. /if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/
  158. /if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/
  159.  
  160. /^[     ]*else true$/c\
  161.     Else\
  162.         mpw-true\
  163.  
  164.  
  165. /else/s/^\([     ]*\)else[     ]*$/\1Else/
  166. /else/s/^\([     ]*\)else[;     ]*\\Option-d$/\1Else/
  167.  
  168. /^[     ]*else[     ]*true[     ]*$/c\
  169.     Else\
  170.         mpw-true
  171.  
  172. /^[     ]*else[     ]*true[;     ]*fi$/c\
  173.     Else\
  174.         mpw-true\
  175.     End If
  176.  
  177. /fi/s/^\([     ]*\)fi *$/\1End/
  178. /fi/s/^\([     ]*\)fi *; *\\Option-d/\1End/
  179.  
  180. # Change looping.
  181. /for/s/^\([     ]*\)for \([-a-zA-Z0-9_]*\) in \([^;]*\); *do *\\Option-d/\1For \2 In \3/
  182. /^\([     ]*\)do *\\Option-d/d
  183. /done/s/^\([     ]*\)done *; *\\Option-d/\1End/
  184. /done/s/^\([     ]*\)done$/\1End/
  185.  
  186. # Trailing semicolons and continued lines are unneeded sh syntax.
  187. /; \\Option-d/s/; \\Option-d//
  188.  
  189. # Change move-if-change to MoveIfChange.
  190. /move-if-change/s/\([^     ]*\)move-if-change/MoveIfChange/g
  191.  
  192. # Change $(SHELL) to the script name by itself.
  193. /SHELL/s/^\([     ]*\){SHELL} /\1/
  194.  
  195. # Change syntax of default rule dependency.
  196. /^\.c\.o/s/^\.c\.o \\Option-f$/.c.o \\Option-f .c/
  197. # Change default rule's action.
  198. /{CC} -c/s/{CC} -c \(.*\) \$<$/{CC} {DepDir}{Default}.c \1 @SEGMENT_FLAG@ -o {TargDir}{Default}.c.o/
  199.  
  200. # This is pretty disgusting, but I can't seem to detect empty rules.
  201. /Option-f$/s/Option-f$/Option-f _oldest/g
  202.  
  203. # Remove -c from explicit compiler calls. (but should not if GCC)
  204. # Handle the case of a source file that is "{xxx}"file.c.
  205. / -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\)\.c/{\1CC}\2 \3"\4"\5.c -o "{o}"\5.c.o/
  206. # Handle the case of a source file that is "{xxx}"dir:file.c.
  207. / -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\):\([-a-z_]*\)\.c/{\1CC}\2 \3"\4"\5:\6.c -o "{o}"\6.c.o/
  208.  
  209. # Change linking cc to linking sequence.
  210. /-o/s/^\([     ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\){LDFLAGS} \(.*\)-o \([^ ]*\) \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \5 -o \6{PROG_EXT} \7\
  211. \1{MAKEPEF} \6{PROG_EXT} -o \6 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
  212. \1{REZ} "{s}"\6.r -o \6 -append -d PROG_NAME='"'\6'"' -d VERSION_STRING='"'{version}'"'/
  213. /-o/s/^\([     ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\)-o \([^ ]*\) \(.*\){LDFLAGS} \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \6 -o \5{PROG_EXT} \7\
  214. \1{MAKEPEF} \5{PROG_EXT} -o \5 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
  215. \1{REZ} "{s}"\5.r -o \5 -append -d PROG_NAME='"'\5'"' -d VERSION_STRING='"'{version}'"'/
  216. /-o/s/^\([     ]*\){HOST_CC} \(.*\)-o \([^ ]*\) \(.*\)$/\1{HOST_CC_LD} \2 -o \3{PROG_EXT} \4\
  217. \1{MAKEPEF} \3{PROG_EXT} -o \3 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
  218. \1{REZ} "{s}"\3.r -o \3 -append -d PROG_NAME='"'\3'"' -d VERSION_STRING='"'{version}'"'/
  219.  
  220. # Comment out .NOEXPORT rules.
  221. /\.NOEXPORT/s/^\.NOEXPORT/#\.NOEXPORT/
  222. # Comment out .PHONY rules.
  223. /\.PHONY/s/^\.PHONY/#\.PHONY/
  224. # Comment out .PRECIOUS rules.
  225. /\.PRECIOUS/s/^\.PRECIOUS/#\.PRECIOUS/
  226. # Comment out .SUFFIXES rules.
  227. /\.SUFFIXES/s/^\.SUFFIXES/#\.SUFFIXES/
  228.  
  229. # Set the install program appropriately.
  230. /INSTALL/s/^INSTALL *= *`.*`:install.sh -c/INSTALL = Duplicate -y/
  231.  
  232. # Don't try to decide whether to use the tree's own tools.
  233. /bison/s/`.*bison:bison.*`/bison -y/
  234. /byacc/s/`.*byacc:byacc.*`/byacc/
  235. /flex/s/`.*flex:flex.*`/flex/
  236.  
  237. # Turn transformed C comments in echo commands back into comments.
  238. /echo/s,echo '\(.*\):\\Option-x\(.*\)\\Option-x:\(.*\)',echo '\1/*\2*/\3',
  239.  
  240. # Whack out various clever expressions that search for tools, since
  241. # the clever code is too /bin/sh specific.
  242.  
  243. /^AR_FOR_TARGET = `/,/`$/c\
  244. AR_FOR_TARGET = ::binutils:ar\
  245.  
  246.  
  247. /^RANLIB_FOR_TARGET = `/,/`$/c\
  248. RANLIB_FOR_TARGET = ::binutils:ranlib\
  249.  
  250.  
  251. /^RANLIB_TEST_FOR_TARGET = /,/ranlib ] )$/c\
  252. RANLIB_TEST_FOR_TARGET = \
  253.  
  254.  
  255. /^EXPECT = `/,/`$/c\
  256. EXPECT = \
  257.  
  258.  
  259. /^RUNTEST = `/,/`$/c\
  260. RUNTEST = \
  261.  
  262.  
  263. /^CC_FOR_TARGET = `/,/`$/c\
  264. CC_FOR_TARGET = \
  265.  
  266.  
  267. /^CXX_FOR_TARGET = `/,/`$/c\
  268. CXX_FOR_TARGET = \
  269.  
  270.  
  271. /^CHILL_FOR_TARGET = `/,/`$/c\
  272. CHILL_FOR_TARGET = \
  273.  
  274.  
  275. /^CHILL_LIB = `/,/`$/c\
  276. CHILL_LIB = \
  277.  
  278. /sanit/s/{start-sanit...-[a-z0-9]*}//
  279. /sanit/s/{end-sanit...-[a-z0-9]*}//
  280.  
  281. # Add standard defines and default rules.
  282. /^# srcdir/a\
  283. \
  284. s = "{srcdir}"\
  285. \
  286. o = :\
  287. \
  288. "{o}" \\Option-f : "{s}"
  289.  
  290.